package com.lottery.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.lottery.entity.CustomerServiceInformation;

public class CRMContext {

	public static CustomerServiceInformation getCustomerServiceInformation() {
		HttpSession session = getSession();
		CustomerServiceInformation customerServiceInformation = (CustomerServiceInformation) session
				.getAttribute("customerServiceInformation");
		return customerServiceInformation;
	}

	public static HttpSession getSession() {
		HttpSession session = null;
		try {
			session = getRequest().getSession();
		} catch (Exception e) {
		}
		return session;
	}

	public static HttpServletRequest getRequest() {
		ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		return attrs.getRequest();
	}

	public static void setCustomerServiceInformation() {
		CustomerServiceInformation CustomerServiceInformation = new CustomerServiceInformation();
		CustomerServiceInformation.setId(1);
		HttpSession session = getSession();
		session.setAttribute("customerServiceInformation", CustomerServiceInformation);
	}

	/*
	 * public static User setUser2(){ User user = new User(); user.setId(1);
	 * return user; }
	 * 
	 * public static User setAdmin(){ User user = new User(); user.setId(3);
	 * return user; }
	 */

}
